<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<% 
/**
 * @Class Name : CertRegistPopup.jsp
 * @Description : 인증서로그인 정보 팝업
 * @Modification Information
 * @
 * @  수정일      수정자            수정내용
 * @ -------        --------    ---------------------------
 * @ 2009.08.13   한성곤          최초 생성
 *
 *  @author 공통컴포넌트개발팀 한성곤
 *  @since 2009.08.13
 *  @version 1.0 
 *  @see
 */
%>
<%@ page import="com.gpki.gpkiapi.cert.*" %>
<%@ page import="com.gpki.gpkiapi.cms.*" %>
<%@ page import="com.gpki.gpkiapi.util.*" %>
<%@ page import="com.dsjdf.jdf.Logger" %>
<%@ page import="com.gpki.gpkiapi.util.Dump" %>
<%@ page import="com.dsjdf.jdf.Utility" %>

<%@include file="EgovCertGpkisecureweb.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/com.css" type="text/css">
<script type="text/javascript" language='javascript' src='${pageContext.request.contextPath}/utl/sec/certVar.do?type=login'></script>
<!-- 
<script type="text/javascript" language='javascript' src='${pageContext.request.contextPath}/resource/gpkisecureweb/install.js' charset="euc-kr"></script>
<script type="text/javascript" language='javascript' src='${pageContext.request.contextPath}/resource/gpkisecureweb/GPKIFunc.js' charset="euc-kr"></script>
<script type="text/javascript" language='javascript' src='${pageContext.request.contextPath}/resource/gpkisecureweb/object.js' charset="euc-kr"></script>
-->
<script type="text/javascript" language='javascript' src='${pageContext.request.contextPath}/js/egovframework/cmm/utl/sec/EgovCertInstall.js'></script>
<script type="text/javascript" language='javascript' src='${pageContext.request.contextPath}/js/egovframework/cmm/utl/sec/EgovCertGPKIFunc.js'></script>
<script type="text/javascript" language='javascript' src='${pageContext.request.contextPath}/js/egovframework/cmm/utl/sec/EgovCertObject.js'></script>
<%
String type = request.getParameter("type");

if (type == null) type = "";

%>
<script type="text/javascript" language="javascript">
<!--
function call_cert(formName) {
	showTooltip();

<% if (type.equals("")) { %>
	if (document.GPKISecureWeb==null || document.GPKISecureWeb.object==null) {
		if (confirm('인증서로그인을 위한 보안프로그램이 설치되지 않았습니다.\n\n설치 후 다시 사용하실 수 있습니다.\n\n설치하시겠습니까?')) {
			document.location.href = '${pageContext.request.contextPath}/utl/sec/certInstall.do?type=regist';
		}

	} else {

		formName.action = '${pageContext.request.contextPath}/utl/sec/certInfoPopup.do?type=regist';
		
		Login(formName);
	}
<% } else {
	X509Certificate cert = null;
	String dn = null;
	
	try {
		cert = gpkirequest.getSignerCert();
		dn = cert.getSubjectDN();
		
	} catch (Exception ex) {
	    ex.printStackTrace();
		StringBuffer sb = new StringBuffer(1500);
		
		sb.append(request.getContextPath()).append("/utl/sec/certGPKIError.do");
        sb.append("?errmsg=");
        sb.append(URLEncoder.encode(ex.getMessage()));
        
        response.sendRedirect(sb.toString()); 	
        return;
	}
%>
	if (typeof(opener.dn_info_setting) == 'undefined') {
		alert('메인 화면이 변경되거나 없습니다');
		this.close();
	} else {
		opener.dn_info_setting('<%= dn %>');
		this.close();
	}
<% } %>
}

function showTooltip() {
	tooltip.style.display = 'block';
}

function hideTooltip() {
	tooltip.style.display = 'none';
}
//-->
</script>


<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="call_cert(myform);">

<noscript class="noScriptTitle">자바스크립트를 지원하지 않는 브라우저에서는 일부 기능을 사용하실 수 없습니다.</noscript>

<FORM name="myform"  method="post">

	<input type=hidden name='type' value='regist'>
	
	<input type="hidden" name="challenge" value="<%= ((GPKIHttpServletResponse)gpkiresponse).getChallenge() %>">

<table border=0 width=100% height=100%>
<tbody>
	<tr width="100%" height="100%">
		<td width="100%" height="100%" align="center" valign="center">
		
		<div id=tooltip align=center
		style='width=80%;
			   height=30;
		       z-index:10;
		       display:none;
		       background-color: #EEF7FE;
		       padding:0px;
		       layer-background-color:#EEF7FE;
		       border: 1px outset #0F7ECB'>
		<marquee behavior=alternate direction=right>
		<font id=divfont class="data" style="font-size:13pt;font-weight:bold;">사용자 인증서 등록 중입니다...<marquee>
	</div>
	</tr>
</tbody>
</table>

</FORM>
</body>
</html>